home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2006 September / SAN CD 9-2006 CD-ROM 16.iso / pc / Software / Network Telescope Control / NTC-Setup.Exe / Source / ntc_client_catalogs.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2006-03-24  |  4.1 KB  |  213 lines

  1. unit ntc_client_catalogs;
  2. {
  3.     Copyright (C) 2004 - 2006 Andrew Sprott
  4.  
  5.     http://astronomy.crysania.co.uk
  6.     astro@trefach.co.uk
  7.  
  8.     This program is free software; you can redistribute it and/or
  9.     modify it under the terms of the GNU General Public License
  10.     as published by the Free Software Foundation; either version 2
  11.     of the License, or (at your option) any later version.
  12.  
  13.     This program is distributed in the hope that it will be useful,
  14.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16.     GNU General Public License for more details.
  17.  
  18.     You should have received a copy of the GNU General Public License
  19.     along with this program; if not, write to the Free Software
  20.     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. }
  22.  
  23. interface
  24.  
  25. uses
  26.     Windows,
  27.     Messages,
  28.     SysUtils,
  29.     Variants,
  30.     Classes,
  31.     Graphics,
  32.     Controls,
  33.     Forms,
  34.     Dialogs,
  35.     StdCtrls,
  36.     ExtCtrls,
  37.     Buttons,
  38.     inifiles,
  39.  
  40.     ntc_client_form;
  41.  
  42. type
  43.   Tscope_catalogs = class(TForm)
  44.     catalogs_panel: TPanel;
  45.     catalogs_group: TGroupBox;
  46.     ComboBox1: TComboBox;
  47.     catalog_label: TLabel;
  48.     number_label: TLabel;
  49.     Edit1: TEdit;
  50.     item_group: TGroupBox;
  51.     visible_label: TLabel;
  52.     visible_edit: TEdit;
  53.     ra_edit: TEdit;
  54.     dec_edit: TEdit;
  55.     ra_label: TLabel;
  56.     Label1: TLabel;
  57.     Label2: TLabel;
  58.     magnitude_edit: TEdit;
  59.     goto_button: TBitBtn;
  60.         { form functions }
  61.         procedure formcreate(
  62.             Sender:TObject);
  63.  
  64.         procedure form_close_query(
  65.                     Sender: TObject;
  66.             var CanClose: Boolean);
  67.  
  68.         { configuration }
  69.         procedure load_settings;
  70.  
  71.         procedure save_settings;
  72.  
  73.         { events }
  74.         procedure FormShow(
  75.             Sender:TObject);
  76.  
  77.         procedure adjust;
  78.  
  79.         procedure check_activate(
  80.             Sender: TObject);
  81.  
  82.     private
  83.         { Private declarations }
  84.     public
  85.         { Public declarations }
  86.         { configuration }
  87.         dimensions:dimensions_record;
  88.  
  89.         { events }
  90.         procedure check_visible_and_show_hide(
  91.             sender:tobject);
  92.             
  93.         procedure hide_form;
  94.         procedure show_form;
  95.     end;
  96.  
  97. var
  98.   scope_catalogs: Tscope_catalogs;
  99.  
  100. implementation
  101.  
  102. {$R *.dfm}
  103.  
  104.     { -------------
  105.         form controls
  106.         ------------- }
  107.  
  108. procedure tscope_catalogs.formcreate(
  109.     Sender:TObject);
  110. begin
  111.     load_settings;
  112. end;
  113.  
  114. procedure tscope_catalogs.form_close_query(
  115.             Sender: TObject;
  116.     var CanClose: Boolean);
  117. begin
  118.     canclose:=false;
  119.     visible:=false;
  120.     with dimensions do
  121.         begin
  122.             form_top:=top;
  123.             form_left:=left;
  124.         end;
  125. end;
  126.  
  127.     { -------------
  128.         configuration
  129.         ------------- }
  130.  
  131. procedure tscope_catalogs.load_settings;
  132. begin
  133.     ini_file:=tinifile.create(application_path+'client.ini');
  134.     with ini_file do
  135.         begin
  136.             { form }
  137.             scope.get_dimensions(scope_catalogs,@dimensions,'catalogs',ini_file);
  138.             left:=dimensions.form_left;
  139.             top:=dimensions.form_top;
  140.             visible:=readbool('catalogs','visible',false);
  141.         end;
  142.     ini_file.free;
  143. end;
  144.  
  145. procedure tscope_catalogs.save_settings;
  146. begin
  147.     with ini_file do
  148.         begin
  149.             { form }
  150.             scope.find_vdu(scope_catalogs,@dimensions);
  151.             scope.write_dimensions(@dimensions,left,top,'catalogs',ini_file);
  152.             writebool('catalogs','visible',visible);
  153.         end;
  154. end;
  155.  
  156.     { ------
  157.         events
  158.         ------ }
  159.  
  160. procedure tscope_catalogs.FormShow(
  161.     Sender:TObject);
  162. begin
  163.     with dimensions do
  164.         begin
  165.             top:=form_top;
  166.             left:=form_left;
  167.         end;
  168. end;
  169.  
  170. procedure tscope_catalogs.adjust;
  171. begin
  172.     with dimensions do
  173.         begin
  174.             form_top:=trunc(form_top/last_screen_height*current_height);
  175.             form_left:=trunc(form_left/last_screen_width*current_width);
  176.         end;
  177.     if visible then
  178.         show;
  179. end;
  180.  
  181. procedure tscope_catalogs.check_visible_and_show_hide(
  182.     sender:tobject);
  183. begin
  184.     if visible then
  185.         hide_form
  186.     else
  187.         show_form;
  188.     scope.show_hide(sender,visible);
  189. end;
  190.  
  191. procedure tscope_catalogs.hide_form;
  192. begin
  193.     with dimensions do
  194.         begin
  195.             form_top:=top;
  196.             form_left:=left;
  197.         end;
  198.     Visible:=false;
  199. end;
  200.  
  201. procedure tscope_catalogs.show_form;
  202. begin
  203.     Visible:=true;
  204. end;
  205.  
  206. procedure tscope_catalogs.check_activate(
  207.     Sender: TObject);
  208. begin
  209.     scope.form_activate(scope_catalogs,@dimensions);
  210. end;
  211.  
  212. end.
  213.